import exhibition from "../../../api/exhibition"
import util from '../../../utils/util'
// components/utils/orderList/orderList.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    order: {
      type: [],
      value: []
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    async gotoOrderDetails(e) {
      const {
        id,
        index
      } = e.currentTarget.dataset;
      console.log(`订单ID: ${id}, 索引: ${index}`);
      console.log(this.data.order[index].name)
      console.log(this.data.order[index].startTime)
      await exhibition.getExhibitionOrderDetail(id, this.data.order[index].name).then(res => {
        console.log(res)
        wx.setStorage({
          key: 'tempOrder',
          data: res.userOrder,
        })
        wx.setStorage({
          key: 'tempExhibitionData',
          data: res.detail,
        })
        let tocalCost=0;
        for(let i=0;i<res.userOrder.length;i++){
          tocalCost=tocalCost+res.userOrder[i].cost;
        }
        wx.setStorage({
          key:'tempCost',
          data: tocalCost,
        })
      }).catch(err => {
        console.log(err)
      })
      wx.navigateTo({
        url: '/pages/order/exhiOrder'
      })

    },
  }
})